package com.ls.fw.data.controller.api;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;

import com.ls.fw.commons.open.annotation.OpenApi;
import com.ls.fw.mvc.springmvc.base.BaseCRUDController;
import com.ls.fw.mvc.springmvc.util.ViewUtil;

@Controller
@RequestMapping(value = "/api")
public class ApiController extends BaseCRUDController
{
    
    private static final int CODE_FAIL = 400;
	private static final String CODE = "code";
	private static final int CODE_SUCCESS = 200;
	private static final String MSG = "msg";

	 
    @RequestMapping(value = "/test")
    @OpenApi
    public ModelAndView save(WebRequest webRequest) throws IOException{
        ModelAndView mav = new ModelAndView("/hello/test");
        int code = CODE_FAIL; 
        Object msg = "";
        msg = "成功";
        code = CODE_SUCCESS; 
        mav.addObject(CODE, code);
        mav.addObject(MSG, msg);
        return ViewUtil.convert(mav, webRequest,true);
    }
   
}
